<?php
defined('BASEPATH') or exit('No direct script access allowed');

/**
 * @model 账户controller，
 */
class AccountController extends Admin_Controller
{

    public function __construct()
    {
        try {
            parent::__construct();
            $this->load->service("PService/AccountService");
            $this->load->service("PService/AuthService");
        } catch (\TPException $e) {
            exit($e->getRetJson());
        }
    }

    /**
     * [accountInfo description]
     * @Description 获取账户信息，包含账户信息、菜单权限、接口权限
     * @Author      FengPQ
     * @OpenFlag    1
     * @DateTime    2020-05-23T16:29:54+0800
     * @return      [type]                             [description]
     */
    public function accountInfo()
    {
        $uuid = $_SESSION[SESS_HEADER]['uuid'];
        $ret['accountInfo'] = $this->AccountService->getAdminInfo($uuid);
        $role_id = $ret['accountInfo']['role_id'];
        log_info($role_id);
        $ret['accountMenu'] = $this->AccountService->getMenuAuth($role_id);
        $ret['accountAction'] = $this->AccountService->getActionAuth($role_id);
        exit(retSucc($ret));
       
    }

    /**
     * 方法名 getAdminAccountList
     * 
     * @Name getAdminAccountList
     * @Desc 获取后台账户列表 分页获取
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2020-12-09 13:13:04 星期三
     * @return      [type]                   [description]
     */
    public function getAdminAccountList(){
        $ret=$this->AccountService->getAccountList(AccountType::Admin[TPEnum::Value],$_POST);
        exit(retSucc($ret));
    }

    /**
     * getAdminAccountExport function
     * 
     * @Name getAdminAccountExport
     * @Desc 获取后台所有列表数据 用于导出
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2020-12-11 10:05:47 星期五
     * @return      [type]                   [description]
     */
    public function getAdminAccountExport(){
        $ret=$this->AccountService->getAccountList(AccountType::Admin[TPEnum::Value],$_POST,true);
        exit(retSucc($ret));
    }

    /**
     * 方法名 getAccountInfo
     * 
     * @Name getAccountInfo
     * @Desc 获取账户信息
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2020-12-10 10:19:50 星期四
     * @return      [array]                   [用户信息]
     */
    public function getAccountInfo(){
        $ret=$this->AccountService->getAdminInfo($_POST['uuid'],true);
        exit(retSucc($ret));
    }
    /**
     * 方法名 saveAdminInfo
     * 
     * @Name saveAdminInfo
     * @Desc 更新后台账户信息
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2020-12-10 12:37:20 星期四
     * @return      [type]                   [description]
     */
    public function saveAdminInfo(){
        $this->AccountService->saveAdminInfo($_POST);
        exit(retSucc());
    }

    /**
     * changeAccountVaild function
     * 
     * @Name changeAccountVaild
     * @Desc 更改后台账户有效状态
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2020-12-10 12:57:06 星期四
     * @return      [type]                   [description]
     */
    public function changeAccountVaild(){
        $this->AccountService->changeAccountVaild($_POST['uuid']);
        exit(retSucc());
    }

    
    /**
     * 方法名 modifyPwd
     * 
     * @Name modifyPwd
     * @Desc 修改密码
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2021-01-07 13:13:05 星期四
     * @return      [type]                   [description]
     */
    public function modifyPwd(){
       $ret=$this->AccountService->modifyPwd($_POST);
       exit(retSucc($ret));
    }

    /**
     * 方法名 getPwd
     * 
     * @Name getPwd
     * @Desc 查询密码是否已过期
     * @OpenFlag 1
     * @Author      LiAnXu
     * @Date 2021-01-07 13:13:05 星期四
     * @return      [type]                   [description]
     */
    public function getPwdJSON(){
        $ret=$this->AccountService->IfPwdTime();
        exit(retSucc($ret));
    }
    
}
